package cn.edu.sdjzu.xg23.kcsj01_backend.mapper;


import cn.edu.sdjzu.xg23.kcsj01_backend.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {



    @Insert("INSERT INTO user(id,username,password,actor_type,actor_id) VALUES (#{id},#{username},#{password},#{actorType},#{actor.id})")
    int addUser(User user);
    // 更新用户登录时间
    @Update("UPDATE user SET last_login_time = now() WHERE id = #{id}")
    int updateLoginTime(Long id);

    //登录查询使用
    User selectByUsernameAndPassword(String username, String password);

    List<User> selectUser(User user);

    @Delete("DELETE FROM user WHERE id = #{id}")
    boolean deleteUser(Long id);

    @Update("UPDATE user SET password = 123456 WHERE id = #{id}")
    boolean resetPassword(Long id);

    @Select("SELECT password FROM user WHERE id = #{id}")
    String selectPasswordById(Long id);

    @Update("UPDATE user SET password = #{password} WHERE id = #{id}")
    boolean updatePassword(User user);

}
